package com.fly.service.Impl;

import com.fly.bean.Defects;
import com.fly.mapper.DefectsMapperO;
import com.fly.service.DefectsServiceO;
import com.fly.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Auther: Orchid
 * @Date: 2019/11/30 17:21
 * @Description:
 */
@Service
public class DefectsServiceOImpl implements DefectsServiceO {

    @Autowired
    DefectsMapperO defectsMapperO;

    @Override
    public List<Defects> queryDefectsByPage(Page page) {

        return defectsMapperO.selectDefectsByPage(page);
    }

    @Override
    public Integer queryAllCount() {

        return defectsMapperO.selectAllCount();
    }

    @Override
    public Boolean updateDefectsState(Defects defects) {

        Integer isUp = defectsMapperO.updateDefectsState(defects);

        if (isUp > 0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public Defects queryDefectsById(Integer defectsId) {

        Defects defects = defectsMapperO.selectDefectsById(defectsId);

        return defects;
    }

    @Override
    public Boolean deleteDefectsById(Integer defectsId) {

        Integer isDel = defectsMapperO.deleteDefectsById(defectsId);

        if (isDel > 0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public Boolean addDefects(Defects defects) {

        Integer isAdd = defectsMapperO.insertDefects(defects);

        if (isAdd > 0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public Boolean queryDefectsByName(String defectsName) {

        Integer isExit = defectsMapperO.selectDefectsByName(defectsName);

        if (isExit > 0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public Boolean queryDefectsIsUse(Integer defectsId) {

        Integer count = defectsMapperO.selectDefectsIsUse(defectsId);

        if (count > 0){
            return true;
        }else {
            return false;
        }

    }

    @Override
    public Boolean queryIsUseInDamage(Integer defectsId) {

        Integer count = defectsMapperO.selectIsUseInDamage(defectsId);

        if (count > 0){
            return true;
        }else {
            return false;
        }

    }
}
